#include "hole.h"

#include <QPainter>
#include <QColor>
#include <QPen>

Hole::Hole(Board *board, qint8 layer, qint32 scene_size, const BoardItem::pos_t &pos)
    : BoardItem(board, scene_size)
    , m_highlighting(false)
{
    setZValue(layer);
    set_game_position(pos);
}

void Hole::setHighlight(bool enable)
{
    m_highlighting = enable;
    update(boundingRect());
}

void Hole::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    if (highlighting())
    {
        QPen pen(Qt::green, 3);
        painter->setPen(pen);
        painter->drawRoundedRect(boundingRect(), item_size()/8, item_size()/8);
    }

    QColor black(Qt::black);
    painter->setBrush(black);
    painter->setPen(black);
    painter->drawEllipse(item_size() / 2 - 2, item_size() / 2 - 2, 4, 4);
}
